home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow_WinXP / VMR / VMRPlayer / app.cpp next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  53.0 KB  |  1,892 lines

  1. //------------------------------------------------------------------------------
  2. // File: app.cpp
  3. //
  4. // Desc: DirectShow sample code
  5. //       - Main source file for VMRPlayer sample
  6. //
  7. // Copyright (c) 1994 - 2001, Microsoft Corporation.  All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10. #include <streams.h>
  11. #include <atlbase.h>
  12. #include <atlconv.cpp>
  13. #include <mmreg.h>
  14. #include <commctrl.h>
  15. #include <stdio.h>
  16.  
  17. #include "project.h"
  18. #include <initguid.h>
  19.  
  20. /* -------------------------------------------------------------------------
  21. ** Global variables that are initialized at run time and then stay constant.
  22. ** -------------------------------------------------------------------------
  23. */
  24. HINSTANCE           hInst;
  25. HICON               hIconVideoCd;
  26. HWND                hwndApp;
  27. HWND                g_hwndToolbar;
  28. HWND                g_hwndStatusbar;
  29. HWND                g_hwndTrackbar;
  30. CMpegMovie          *pMpegMovie;
  31. double              g_TrackBarScale = 1.0;
  32. BOOL                g_bPlay = FALSE;
  33. BOOL                g_fEnableAppImage;
  34. BOOL                g_bSecondFileLoaded = FALSE;
  35.  
  36. int                 dyToolbar, dyStatusbar, dyTrackbar;
  37. int                 FrameStepCount;
  38.  
  39. FLOAT               g_xPos = 0.25F, g_yPos = 0.25F;
  40. FLOAT               g_xSize = 0.5F, g_ySize = 0.5F;
  41. FLOAT               g_Alpha = 0.5F;
  42.  
  43. typedef struct
  44. {
  45.     FLOAT               xPos,  yPos;
  46.     FLOAT               xSize, ySize;
  47.     FLOAT               Alpha;
  48. } STRM_PARAM;
  49.  
  50. const STRM_PARAM strParamInit[1] = {
  51.     {0.0F, 0.0F, 1.0F, 1.0F, 1.0F}
  52. };
  53.  
  54. STRM_PARAM strParam[2] = {
  55.     {0.0F, 0.0F, 1.0F, 1.0F, 1.0F},
  56.     {0.0F, 0.0F, 1.0F, 1.0F, 0.0F}
  57. };
  58.  
  59.  
  60. /* -------------------------------------------------------------------------
  61. ** True Globals - these may change during execution of the program.
  62. ** -------------------------------------------------------------------------
  63. */
  64. TCHAR               g_achFileName[MAX_PATH];
  65. OPENFILENAME        ofn;
  66. DWORD               g_State = VCD_NO_CD;
  67. LONG                lMovieOrgX, lMovieOrgY;
  68. int                 g_TimeFormat = IDM_TIME;
  69.  
  70.  
  71. /* -------------------------------------------------------------------------
  72. ** Constants
  73. ** -------------------------------------------------------------------------
  74. */
  75. #define STRM_A  0
  76. #define STRM_B  1
  77.  
  78. const TCHAR szClassName[] = TEXT("VMRPlayer_CLASS");
  79. const TCHAR g_szNULL[]    = TEXT("\0");
  80. const TCHAR g_szEmpty[]   = TEXT("");
  81. const TCHAR g_szMovieX[]  = TEXT("MovieOriginX");
  82. const TCHAR g_szMovieY[]  = TEXT("MovieOriginY");
  83.  
  84. const int   dxBitmap        = 16;
  85. const int   dyBitmap        = 15;
  86. const int   dxButtonSep     = 8;
  87. const TCHAR g_chNULL        = TEXT('\0');
  88.  
  89. const TBBUTTON tbButtons[DEFAULT_TBAR_SIZE] = {
  90.     { IDX_SEPARATOR,    1,                    0,               TBSTYLE_SEP           },
  91.     { IDX_1,            IDM_MOVIE_PLAY,       TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  92.     { IDX_2,            IDM_MOVIE_PAUSE,      TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  93.     { IDX_3,            IDM_MOVIE_STOP,       TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  94.     { IDX_SEPARATOR,    2,                    0,               TBSTYLE_SEP           },
  95.     { IDX_4,            IDM_MOVIE_PREVTRACK,  TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  96.     { IDX_5,            IDM_MOVIE_SKIP_BACK,  TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  97.     { IDX_6,            IDM_MOVIE_SKIP_FORE,  TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 },
  98.     { IDX_SEPARATOR,    3,                    0,               TBSTYLE_SEP           },
  99.     { IDX_12,           IDM_MOVIE_STEP,       TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, -1 }
  100. };
  101.  
  102. const int CX_MOVIE_DEFAULT    = 352;
  103. const int CY_MOVIE_DEFAULT    = 120;
  104.  
  105.  
  106.  
  107. /******************************Public*Routine******************************\
  108. * WinMain
  109. *
  110. *
  111. * Windows recognizes this function by name as the initial entry point
  112. * for the program.  This function calls the application initialization
  113. * routine, if no other instance of the program is running, and always
  114. * calls the instance initialization routine.  It then executes a message
  115. * retrieval and dispatch loop that is the top-level control structure
  116. * for the remainder of execution.  The loop is terminated when a WM_QUIT
  117. * message is received, at which time this function exits the application
  118. * instance by returning the value passed by PostQuitMessage().
  119. *
  120. * If this function must abort before entering the message loop, it
  121. * returns the conventional value FALSE.
  122. *
  123. \**************************************************************************/
  124. int PASCAL
  125. WinMain(
  126.     HINSTANCE hInstance,
  127.     HINSTANCE hPrevInstance,
  128.     LPSTR lpCmdLineOld,
  129.     int nCmdShow
  130.     )
  131. {
  132.     USES_CONVERSION;
  133.     LPTSTR lpCmdLine = A2T(lpCmdLineOld);
  134.  
  135.     HRESULT hres = CoInitialize(NULL);
  136.     if(hres == S_FALSE)
  137.     {
  138.         CoUninitialize();
  139.         return FALSE;
  140.     }
  141.  
  142.     if(!hPrevInstance)
  143.     {
  144.         if(!InitApplication(hInstance))
  145.         {
  146.             return FALSE;
  147.         }
  148.     }
  149.  
  150.     /*
  151.     ** Perform initializations that apply to a specific instance
  152.     */
  153.     if(!InitInstance(hInstance, nCmdShow))
  154.     {
  155.         return FALSE;
  156.     }
  157.  
  158.     /* Verify that the VMR is present on this system */
  159.     if(!VerifyVMR())
  160.         return FALSE;
  161.  
  162.     /* Look for options */
  163.     while(lpCmdLine && (*lpCmdLine == '-' || *lpCmdLine == '/'))
  164.     {
  165.         if ((lpCmdLine[1] == 'P') || (lpCmdLine[1] == 'p'))
  166.         {
  167.             g_bPlay = TRUE;
  168.             lpCmdLine += 2;
  169.         }
  170.         else
  171.         {
  172.             break;
  173.         }
  174.         while(lpCmdLine[0] == ' ')
  175.         {
  176.             lpCmdLine++;
  177.         }
  178.     }
  179.  
  180.     if(lpCmdLine != NULL && lstrlen(lpCmdLine) > 0)
  181.     {
  182.         ProcessOpen(lpCmdLine, g_bPlay);
  183.         SetPlayButtonsEnableState();
  184.     }
  185.  
  186.     /*
  187.     ** Acquire and dispatch messages until a WM_QUIT message is received.
  188.     */
  189.     return DoMainLoop();
  190. }
  191.  
  192.  
  193. /*****************************Private*Routine******************************\
  194. * DoMainLoop
  195. *
  196. * Process the main message loop
  197. *
  198. \**************************************************************************/
  199. int
  200. DoMainLoop(
  201.     void
  202.     )
  203. {
  204.     MSG         msg;
  205.     HANDLE      ahObjects[1];   // handles that need to be waited on
  206.     const int   cObjects = 1;   // no of objects that we are waiting on
  207.     HACCEL      haccel = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACCELERATOR));
  208.  
  209.     //
  210.     // message loop lasts until we get a WM_QUIT message
  211.     // upon which we shall return from the function
  212.     //
  213.  
  214.     for(;;)
  215.     {
  216.         if(pMpegMovie != NULL)
  217.         {
  218.             ahObjects[0] = pMpegMovie->GetMovieEventHandle();
  219.         }
  220.         else
  221.         {
  222.             ahObjects[0] = NULL;
  223.         }
  224.  
  225.         if(ahObjects[0] == NULL)
  226.         {
  227.             WaitMessage();
  228.         }
  229.         else
  230.         {
  231.             //
  232.             // wait for any message sent or posted to this queue
  233.             // or for a graph notification
  234.             //
  235.             DWORD result;
  236.  
  237.             result = MsgWaitForMultipleObjects(cObjects, ahObjects, FALSE,
  238.                 INFINITE, QS_ALLINPUT);
  239.             if(result != (WAIT_OBJECT_0 + cObjects))
  240.             {
  241.                 if(result == WAIT_OBJECT_0)
  242.                     VideoCd_OnGraphNotify();
  243.  
  244.                 continue;
  245.             }
  246.         }
  247.  
  248.         //
  249.         // When here, we either have a message or no event handle
  250.         // has been created yet.
  251.         //
  252.         // read all of the messages in this next loop
  253.         // removing each message as we read it
  254.         //
  255.  
  256.         while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  257.         {
  258.             if(msg.message == WM_QUIT)
  259.             {
  260.                 return (int) msg.wParam;
  261.             }
  262.  
  263.             if(!TranslateAccelerator(hwndApp, haccel, &msg))
  264.             {
  265.                 TranslateMessage(&msg);
  266.                 DispatchMessage(&msg);
  267.             }
  268.         }
  269.     }
  270.  
  271. } // DoMainLoop
  272.  
  273.  
  274. /*****************************Private*Routine******************************\
  275. * InitApplication(HANDLE)
  276. *
  277. * This function is called at initialization time only if no other
  278. * instances of the application are running.  This function performs
  279. * initialization tasks that can be done once for any number of running
  280. * instances.
  281. *
  282. * In this case, we initialize a window class by filling out a data
  283. * structure of type WNDCLASS and calling the Windows RegisterClass()
  284. * function.  Since all instances of this application use the same window
  285. * class, we only need to do this when the first instance is initialized.
  286. *
  287. \**************************************************************************/
  288. BOOL
  289. InitApplication(
  290.     HINSTANCE hInstance
  291.     )
  292. {
  293.     WNDCLASS  wc;
  294.  
  295.     /*
  296.     ** Fill in window class structure with parameters that describe the
  297.     ** main window.
  298.     */
  299.     hIconVideoCd     = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_VIDEOCD_ICON));
  300.  
  301.     wc.style         = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
  302.     wc.lpfnWndProc   = VideoCdWndProc;
  303.     wc.cbClsExtra    = 0;
  304.     wc.cbWndExtra    = 0;
  305.     wc.hInstance     = hInstance;
  306.     wc.hIcon         = hIconVideoCd;
  307.     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  308.     wc.hbrBackground = (HBRUSH)NULL; // (COLOR_BTNFACE + 1);
  309.     wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAIN_MENU);
  310.     wc.lpszClassName = szClassName;
  311.  
  312.     OSVERSIONINFO OSVer;
  313.     OSVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  314.     BOOL bRet = GetVersionEx((LPOSVERSIONINFO) &OSVer);
  315.     ASSERT(bRet);
  316.  
  317.     /*
  318.     ** Register the window class and return success/failure code.
  319.     */
  320.     return RegisterClass(&wc);
  321. }
  322.  
  323.  
  324. /*****************************Private*Routine******************************\
  325. * InitInstance
  326. *
  327. *
  328. * This function is called at initialization time for every instance of
  329. * this application.  This function performs initialization tasks that
  330. * cannot be shared by multiple instances.
  331. *
  332. * In this case, we save the instance handle in a static variable and
  333. * create and display the main program window.
  334. *
  335. \**************************************************************************/
  336. BOOL
  337. InitInstance(
  338.     HINSTANCE hInstance,
  339.     int nCmdShow
  340.     )
  341. {
  342.     HWND    hwnd;
  343.     RECT    rc;
  344.     POINT   pt;
  345.  
  346.     /*
  347.     ** Save the instance handle in static variable, which will be used in
  348.     ** many subsequence calls from this application to Windows.
  349.     */
  350.     hInst = hInstance;
  351.  
  352.     if(! LoadWindowPos(&rc))
  353.         rc.left = rc.top = CW_USEDEFAULT;
  354.  
  355.     /*
  356.     ** Create a main window for this application instance.
  357.     */
  358.     hwnd = CreateWindow(szClassName, IdStr(STR_APP_TITLE),
  359.         WS_THICKFRAME | WS_POPUP | WS_CAPTION  |
  360.         WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
  361.         WS_CLIPCHILDREN,
  362.         rc.left, rc.top,
  363.         rc.right - rc.left, rc.bottom - rc.top,
  364.         NULL, NULL, hInstance, NULL);
  365.  
  366.     /*
  367.     ** If window could not be created, return "failure"
  368.     */
  369.     if(NULL == hwnd)
  370.     {
  371.         return FALSE;
  372.     }
  373.  
  374.  
  375.     hwndApp = hwnd;
  376.     nRecentFiles = GetRecentFiles(nRecentFiles);
  377.  
  378.     pt.x = lMovieOrgX =  ProfileIntIn(g_szMovieX, 0);
  379.     pt.y = lMovieOrgY =  ProfileIntIn(g_szMovieY, 0);
  380.  
  381.     // if we fail to get the working area (screen-tray), then assume
  382.     // the screen is 640x480
  383.     //
  384.     if(!SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE))
  385.     {
  386.         rc.top = rc.left = 0;
  387.         rc.right = 640;
  388.         rc.bottom = 480;
  389.     }
  390.  
  391.     if(!PtInRect(&rc, pt))
  392.     {
  393.         lMovieOrgX = lMovieOrgY = 0L;
  394.     }
  395.  
  396.     /*
  397.     ** Make the window visible; update its client area; and return "success"
  398.     */
  399.     SetPlayButtonsEnableState();
  400.     ShowWindow(hwnd, nCmdShow);
  401.     UpdateWindow(hwnd);
  402.  
  403.     return TRUE;
  404. }
  405.  
  406. /*****************************Private*Routine******************************\
  407. * GetMoviePosition
  408. *
  409. * Place the movie in the centre of the client window.  We do not stretch the
  410. * the movie yet !
  411. *
  412. \**************************************************************************/
  413. void
  414. GetMoviePosition(
  415.     HWND hwnd,
  416.     long* xPos,
  417.     long* yPos,
  418.     long* pcx,
  419.     long* pcy
  420.     )
  421. {
  422.     RECT rc;
  423.     GetClientRect(hwnd, &rc);
  424.  
  425.     rc.top += (dyToolbar + dyTrackbar);
  426.     rc.bottom -= dyStatusbar;
  427.  
  428.     *xPos = rc.left;
  429.     *yPos = rc.top;
  430.     *pcx = rc.right - rc.left;
  431.     *pcy = rc.bottom - rc.top;
  432. }
  433.  
  434.  
  435. /*****************************Private*Routine******************************\
  436. * RepositionMovie
  437. *
  438. \**************************************************************************/
  439. void
  440. RepositionMovie(HWND hwnd)
  441. {
  442.     if(pMpegMovie)
  443.     {
  444.         long xPos, yPos, cx, cy;
  445.         GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy);
  446.         pMpegMovie->PutMoviePosition(xPos, yPos, cx, cy);
  447.  
  448.         HDC hdcWin = GetDC(NULL);
  449.         pMpegMovie->RepaintVideo(hwnd, hdcWin);
  450.         ReleaseDC(hwnd, hdcWin);
  451.     }
  452. }
  453.  
  454. /*****************************Private*Routine******************************\
  455. * VideoCd_OnMove
  456. *
  457. \**************************************************************************/
  458. void
  459. VideoCd_OnMove(
  460.     HWND hwnd,
  461.     int x,
  462.     int y
  463.     )
  464. {
  465.     if(pMpegMovie)
  466.     {
  467.         if(pMpegMovie->GetStateMovie() != State_Running)
  468.         {
  469.             RepositionMovie(hwnd);
  470.         }
  471.         else
  472.         {
  473.             long xPos, yPos, cx, cy;
  474.  
  475.             // Reposition movie but don't invalidate the rect, since
  476.             // the next video frame will handle the redraw.
  477.             GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy);
  478.             pMpegMovie->PutMoviePosition(xPos, yPos, cx, cy);
  479.         }
  480.     }
  481. }
  482.  
  483.  
  484. /******************************Public*Routine******************************\
  485. * VideoCdWndProc
  486. *
  487. \**************************************************************************/
  488. LRESULT CALLBACK
  489. VideoCdWndProc(
  490.     HWND hwnd,
  491.     UINT message,
  492.     WPARAM wParam,
  493.     LPARAM lParam
  494.     )
  495. {
  496.     switch(message)
  497.     {
  498.         HANDLE_MSG(hwnd, WM_CREATE,            VideoCd_OnCreate);
  499.         HANDLE_MSG(hwnd, WM_PAINT,             VideoCd_OnPaint);
  500.         HANDLE_MSG(hwnd, WM_COMMAND,           VideoCd_OnCommand);
  501.         HANDLE_MSG(hwnd, WM_CLOSE,             VideoCd_OnClose);
  502.         HANDLE_MSG(hwnd, WM_QUERYENDSESSION,   VideoCd_OnQueryEndSession);
  503.         HANDLE_MSG(hwnd, WM_DESTROY,           VideoCd_OnDestroy);
  504.         HANDLE_MSG(hwnd, WM_SIZE,              VideoCd_OnSize);
  505.         HANDLE_MSG(hwnd, WM_SYSCOLORCHANGE,    VideoCd_OnSysColorChange);
  506.         HANDLE_MSG(hwnd, WM_MENUSELECT,        VideoCd_OnMenuSelect);
  507.         HANDLE_MSG(hwnd, WM_INITMENUPOPUP,     VideoCd_OnInitMenuPopup);
  508.         HANDLE_MSG(hwnd, WM_HSCROLL,           VideoCd_OnHScroll);
  509.         HANDLE_MSG(hwnd, WM_TIMER,             VideoCd_OnTimer);
  510.         HANDLE_MSG(hwnd, WM_NOTIFY,            VideoCd_OnNotify);
  511.         HANDLE_MSG(hwnd, WM_DROPFILES,         VideoCd_OnDropFiles);
  512.         HANDLE_MSG(hwnd, WM_MOVE,              VideoCd_OnMove);
  513.  
  514.         case WM_RBUTTONDBLCLK:
  515.         case WM_RBUTTONDOWN:
  516.             VcdPlyerCaptureImage(CAPTURED_IMAGE_NAME);
  517.             break;
  518.  
  519.         case WM_DISPLAYCHANGE:
  520.             if(pMpegMovie)
  521.                 pMpegMovie->DisplayModeChanged();
  522.             break;
  523.  
  524.         // Note: we do not use HANDLE_MSG here as we want to call
  525.         // DefWindowProc after we have notifed the FilterGraph Resource Manager,
  526.         // otherwise our window will not finish its activation process.
  527.  
  528.         case WM_ACTIVATE: VideoCd_OnActivate(hwnd, wParam, lParam);
  529.  
  530.             // IMPORTANT - let this drop through to DefWindowProc
  531.  
  532.         default:
  533.             return DefWindowProc(hwnd, message, wParam, lParam);
  534.     }
  535.  
  536.     return 0L;
  537. }
  538.  
  539.  
  540. /*****************************Private*Routine******************************\
  541. * VideoCd_OnCreate
  542. *
  543. \**************************************************************************/
  544. BOOL
  545. VideoCd_OnCreate(
  546.     HWND hwnd,
  547.     LPCREATESTRUCT lpCreateStruct
  548.     )
  549. {
  550.     RECT rc;
  551.     int Pane[2];
  552.  
  553.     InitCommonControls();
  554.  
  555.     /*
  556.     ** Create the toolbar and statusbar.
  557.     */
  558.     g_hwndToolbar = CreateToolbarEx(hwnd,
  559.         WS_VISIBLE | WS_CHILD |
  560.         TBSTYLE_TOOLTIPS | CCS_NODIVIDER,
  561.         ID_TOOLBAR, NUMBER_OF_BITMAPS,
  562.         hInst, IDR_TOOLBAR, tbButtons,
  563.         DEFAULT_TBAR_SIZE, dxBitmap, dyBitmap,
  564.         dxBitmap, dyBitmap, sizeof(TBBUTTON));
  565.  
  566.     if(g_hwndToolbar == NULL)
  567.         return FALSE;
  568.  
  569.     g_hwndStatusbar = CreateStatusWindow(WS_VISIBLE | WS_CHILD | CCS_BOTTOM,
  570.         TEXT("Example Text"),
  571.         hwnd, ID_STATUSBAR);
  572.  
  573.     GetWindowRect(g_hwndToolbar, &rc);
  574.     dyToolbar = rc.bottom - rc.top;
  575.  
  576.     GetWindowRect(g_hwndStatusbar, &rc);
  577.     dyStatusbar = rc.bottom - rc.top;
  578.  
  579.     dyTrackbar = 30;
  580.  
  581.     GetClientRect(hwnd, &rc);
  582.     Pane[0] = (rc.right - rc.left) / 2 ;
  583.     Pane[1] = -1;
  584.     SendMessage(g_hwndStatusbar, SB_SETPARTS, 2, (LPARAM)Pane);
  585.  
  586.  
  587.     g_hwndTrackbar = CreateWindowEx(0, TRACKBAR_CLASS, TEXT("Trackbar Control"),
  588.         WS_CHILD | WS_VISIBLE |
  589.         TBS_AUTOTICKS | TBS_ENABLESELRANGE,
  590.         LEFT_MARGIN, dyToolbar - 1,
  591.         (rc.right - rc.left) - (2* LEFT_MARGIN),
  592.         dyTrackbar, hwnd, (HMENU)ID_TRACKBAR,
  593.         hInst, NULL);
  594.  
  595.     SetDurationLength((REFTIME)0);
  596.     SetCurrentPosition((REFTIME)0);
  597.  
  598.     SetTimer(hwnd, StatusTimer, 500, NULL);
  599.  
  600.     if(g_hwndStatusbar == NULL || g_hwndTrackbar == NULL)
  601.     {
  602.         return FALSE;
  603.     }
  604.  
  605.     // accept filemanager WM_DROPFILES messages
  606.     DragAcceptFiles(hwnd, TRUE);
  607.  
  608.     return TRUE;
  609. }
  610.  
  611. /*****************************Private*Routine******************************\
  612. * VideoCd_OnActivate
  613. *
  614. \**************************************************************************/
  615. void
  616. VideoCd_OnActivate(
  617.     HWND hwnd,
  618.     WPARAM wParam,
  619.     LPARAM lParam
  620.     )
  621. {
  622.     if((UINT)LOWORD(wParam))
  623.     {
  624.         // we are being activated - tell the Filter graph (for Sound follows focus)
  625.         if(pMpegMovie)
  626.         {
  627.             pMpegMovie->SetFocus();
  628.         }
  629.     }
  630. }
  631.  
  632.  
  633. /*****************************Private*Routine******************************\
  634. * VideoCd_OnHScroll
  635. *
  636. \**************************************************************************/
  637. void
  638. VideoCd_OnHScroll(
  639.     HWND hwnd,
  640.     HWND hwndCtl,
  641.     UINT code,
  642.     int pos
  643.     )
  644. {
  645.     static BOOL fWasPlaying = FALSE;
  646.     static BOOL fBeginScroll = FALSE;
  647.  
  648.     if(pMpegMovie == NULL)
  649.     {
  650.         return;
  651.     }
  652.  
  653.     if(hwndCtl == g_hwndTrackbar)
  654.     {
  655.         REFTIME     rtCurrPos;
  656.         REFTIME     rtTrackPos;
  657.         REFTIME     rtDuration;
  658.  
  659.         pos = (int)SendMessage(g_hwndTrackbar, TBM_GETPOS, 0, 0);
  660.         rtTrackPos = (REFTIME)pos * g_TrackBarScale;
  661.  
  662.         switch(code)
  663.         {
  664.             case TB_BOTTOM:
  665.                 rtDuration = pMpegMovie->GetDuration();
  666.                 rtCurrPos = pMpegMovie->GetCurrentPosition();
  667.                 VcdPlayerSeekCmd(rtDuration - rtCurrPos);
  668.                 SetCurrentPosition(pMpegMovie->GetCurrentPosition());
  669.                 break;
  670.  
  671.             case TB_TOP:
  672.                 rtCurrPos = pMpegMovie->GetCurrentPosition();
  673.                 VcdPlayerSeekCmd(-rtCurrPos);
  674.                 SetCurrentPosition(pMpegMovie->GetCurrentPosition());
  675.                 break;
  676.  
  677.             case TB_LINEDOWN:
  678.                 VcdPlayerSeekCmd(10.0);
  679.                 SetCurrentPosition(pMpegMovie->GetCurrentPosition());
  680.                 break;
  681.  
  682.             case TB_LINEUP:
  683.                 VcdPlayerSeekCmd(-10.0);
  684.                 SetCurrentPosition(pMpegMovie->GetCurrentPosition());
  685.                 break;
  686.  
  687.             case TB_ENDTRACK:
  688.                 fBeginScroll = FALSE;
  689.                 if(fWasPlaying)
  690.                 {
  691.                     VcdPlayerPauseCmd();
  692.                     fWasPlaying = FALSE;
  693.                 }
  694.                 break;
  695.  
  696.             case TB_THUMBTRACK:
  697.                 if(!fBeginScroll)
  698.                 {
  699.                     fBeginScroll = TRUE;
  700.                     fWasPlaying = (g_State & VCD_PLAYING);
  701.                     if(fWasPlaying)
  702.                     {
  703.                         VcdPlayerPauseCmd();
  704.                     }
  705.                 }
  706.                 // Fall through to PAGEUP/PAGEDOWN processing
  707.  
  708.             case TB_PAGEUP:
  709.             case TB_PAGEDOWN:
  710.                 rtCurrPos = pMpegMovie->GetCurrentPosition();
  711.                 VcdPlayerSeekCmd(rtTrackPos - rtCurrPos);
  712.                 SetCurrentPosition(pMpegMovie->GetCurrentPosition());
  713.                 break;
  714.         }
  715.     }
  716. }
  717.  
  718.  
  719. /*****************************Private*Routine******************************\
  720. * VideoCd_OnTimer
  721. *
  722. \**************************************************************************/
  723. void
  724. VideoCd_OnTimer(
  725.     HWND hwnd,
  726.     UINT id
  727.     )
  728. {
  729.     if(pMpegMovie && pMpegMovie->StatusMovie() == MOVIE_PLAYING)
  730.     {
  731.         switch(id)
  732.         {
  733.             case StatusTimer:
  734.             {
  735.                 REFTIME rt = pMpegMovie->GetCurrentPosition();
  736.                 SetCurrentPosition(rt);
  737.  
  738.                 if(1)
  739.                 {
  740.                     TCHAR   szFmt[64];
  741.                     TCHAR   sz[64];
  742.                     long cx, cy;
  743.  
  744.                     pMpegMovie->GetNativeMovieSize(&cx, &cy);
  745.                     wsprintf(sz, TEXT("%s"), FormatRefTime(szFmt, rt));
  746.  
  747.                     HDC hdc = GetDC(hwndApp);
  748.                     HBITMAP hbmp = CreateCompatibleBitmap(hdc, 128, 128);
  749.                     HBITMAP hbmpVmr = LoadBitmap(hInst, MAKEINTRESOURCE(IDR_VMR));
  750.                     HDC hdcBmp = CreateCompatibleDC(hdc);
  751.                     HDC hdcVMR = CreateCompatibleDC(hdc);
  752.                     ReleaseDC(hwndApp, hdc);
  753.  
  754.                     HBITMAP hbmpold = (HBITMAP)SelectObject(hdcBmp, hbmp);
  755.                     hbmpVmr = (HBITMAP)SelectObject(hdcVMR, hbmpVmr);
  756.                     BitBlt(hdcBmp, 0, 0, 128, 128, hdcVMR, 0, 0, SRCCOPY);
  757.                     DeleteObject(SelectObject(hdcVMR, hbmpVmr));
  758.                     DeleteDC(hdcVMR);
  759.  
  760.                     RECT rc;
  761.                     SetRect(&rc, 0, 0, 128, 32);
  762.                     SetBkColor(hdcBmp, RGB(0, 0, 128));
  763.                     SetTextColor(hdcBmp, RGB(255, 255, 255));
  764.  
  765.                     DrawText(hdcBmp, sz, lstrlen(sz), &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  766.  
  767.                     VMRALPHABITMAP bmpInfo;
  768.                     ZeroMemory(&bmpInfo, sizeof(bmpInfo));
  769.                     bmpInfo.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
  770.                     bmpInfo.hdc = hdcBmp;
  771.                     SetRect(&rc, 0, 0, 128, 128);
  772.                     bmpInfo.rSrc = rc;
  773.  
  774.                     bmpInfo.rDest.left = g_xPos;
  775.                     bmpInfo.rDest.top = g_yPos;
  776.                     bmpInfo.rDest.right = g_xPos + g_xSize;
  777.                     bmpInfo.rDest.bottom = g_yPos + g_ySize;
  778.  
  779.                     if(g_fEnableAppImage)
  780.                     {
  781.                         bmpInfo.fAlpha = g_Alpha;
  782.                     }
  783.                     else
  784.                     {
  785.                         bmpInfo.fAlpha = 0.0F;
  786.                     }
  787.                     bmpInfo.clrSrcKey = 0;
  788.  
  789.                     pMpegMovie->SetAppImage(&bmpInfo);
  790.  
  791.                     DeleteObject(SelectObject(hdcBmp, hbmpold));
  792.                     DeleteDC(hdcBmp);
  793.                 }
  794.             }
  795.             break;
  796.         }
  797.     }
  798. }
  799.  
  800.  
  801. /*****************************Private*Routine******************************\
  802. * VideoCd_OnPaint
  803. *
  804. \**************************************************************************/
  805. void
  806. VideoCd_OnPaint(
  807.     HWND hwnd
  808.     )
  809. {
  810.     PAINTSTRUCT ps;
  811.     HDC         hdc;
  812.     RECT        rc1;
  813.     RECT        rc2;
  814.  
  815.     /*
  816.     ** Draw a frame around the movie playback area.
  817.     */
  818.     GetClientRect(hwnd, &rc2);
  819.  
  820.     hdc = BeginPaint(hwnd, &ps);
  821.  
  822.     if(pMpegMovie)
  823.     {
  824.         long xPos, yPos, cx, cy;
  825.         GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy);
  826.         SetRect(&rc1, xPos, yPos, xPos + cx, yPos + cy);
  827.  
  828.         HRGN rgnClient = CreateRectRgnIndirect(&rc2);
  829.         HRGN rgnVideo  = CreateRectRgnIndirect(&rc1);
  830.         CombineRgn(rgnClient, rgnClient, rgnVideo, RGN_DIFF);
  831.  
  832.         HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE);
  833.         FillRgn(hdc, rgnClient, hbr);
  834.         DeleteObject(hbr);
  835.         DeleteObject(rgnClient);
  836.         DeleteObject(rgnVideo);
  837.  
  838.         pMpegMovie->RepaintVideo(hwnd, hdc);
  839.     }
  840.     else
  841.     {
  842.         FillRect(hdc, &rc2, (HBRUSH)(COLOR_BTNFACE + 1));
  843.     }
  844.  
  845.     EndPaint(hwnd, &ps);
  846. }
  847.  
  848.  
  849. /*****************************Private*Routine******************************\
  850. * VideoCd_OnCommand
  851. *
  852. \**************************************************************************/
  853. void
  854. VideoCd_OnCommand(
  855.     HWND hwnd,
  856.     int id,
  857.     HWND hwndCtl,
  858.     UINT codeNotify
  859.     )
  860. {
  861.     switch(id)
  862.     {
  863.         case IDM_FILE_OPEN:
  864.             VcdPlayerCloseCmd();
  865.             VcdPlayerOpenCmd(STRM_A);
  866.             break;
  867.  
  868.         case IDM_FILE_OPEN2:
  869.             VcdPlayerOpenCmd(STRM_B);
  870.             break;
  871.  
  872.         case IDM_FILE_CLOSE:
  873.             VcdPlayerCloseCmd();
  874.             QzFreeUnusedLibraries();
  875.             break;
  876.  
  877.         case IDM_FILE_EXIT:
  878.             PostMessage(hwnd, WM_CLOSE, 0, 0L);
  879.             break;
  880.  
  881.         case IDM_MOVIE_PLAY:
  882.             VcdPlayerPlayCmd();
  883.             break;
  884.  
  885.         case IDM_MOVIE_STOP:
  886.             VcdPlayerStopCmd();
  887.             break;
  888.  
  889.         case IDM_MOVIE_PAUSE:
  890.             VcdPlayerPauseCmd();
  891.             break;
  892.  
  893.         case IDM_MOVIE_SKIP_FORE:
  894.             VcdPlayerSeekCmd(1.0);
  895.             break;
  896.  
  897.         case IDM_MOVIE_SKIP_BACK:
  898.             VcdPlayerSeekCmd(-1.0);
  899.             break;
  900.  
  901.         case IDM_MOVIE_PREVTRACK:
  902.             if(pMpegMovie)
  903.             {
  904.                 VcdPlayerSeekCmd(-pMpegMovie->GetCurrentPosition());
  905.             }
  906.             break;
  907.  
  908.         case IDM_MOVIE_STEP:
  909.             VcdPlayerStepCmd();
  910.             break;
  911.  
  912.         case IDM_APP_IMAGE:
  913.             DialogBox(hInst, MAKEINTRESOURCE(IDD_AUDIOPROP), hwnd, AppImgDlgProc);
  914.             break;
  915.  
  916.         case IDM_STREAM_A:
  917.             DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUDIOPROP), hwnd,
  918.                 TransDlgProc, (LPARAM)STRM_A);
  919.             break;
  920.  
  921.         case IDM_STREAM_B:
  922.             DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUDIOPROP), hwnd,
  923.                 TransDlgProc, (LPARAM)STRM_B);
  924.             break;
  925.  
  926.         case IDM_CAPTURE_IMAGE:
  927.             VcdPlyerCaptureImage(CAPTURED_IMAGE_NAME);
  928.             break;
  929.  
  930.         case IDM_DISPLAY_CAPTURED_IMAGE:
  931.             VcdPlyerDisplayCapturedImage(CAPTURED_IMAGE_NAME);
  932.             break;
  933.  
  934.         case IDM_HELP_ABOUT:
  935.             DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX),
  936.                 hwnd,  (DLGPROC) AboutDlgProc);
  937.             break;
  938.  
  939.         default:
  940.             if(id > ID_RECENT_FILE_BASE
  941.                 && id <= (ID_RECENT_FILE_BASE + MAX_RECENT_FILES + 1))
  942.             {
  943.                 ProcessOpen(aRecentFiles[id - ID_RECENT_FILE_BASE - 1]);
  944.             }
  945.             break;
  946.     }
  947.  
  948.     SetPlayButtonsEnableState();
  949. }
  950.  
  951.  
  952. /******************************Public*Routine******************************\
  953. * VideoCd_OnDestroy
  954. *
  955. \**************************************************************************/
  956. void
  957. VideoCd_OnDestroy(
  958.     HWND hwnd
  959.     )
  960. {
  961.     PostQuitMessage(0);
  962. }
  963.  
  964.  
  965. /******************************Public*Routine******************************\
  966. * VideoCd_OnClose
  967. *
  968. \**************************************************************************/
  969. void
  970. VideoCd_OnClose(
  971.     HWND hwnd
  972.     )
  973. {
  974.     // stop accepting dropped filenames
  975.     DragAcceptFiles(hwnd, FALSE);
  976.  
  977.     VcdPlayerCloseCmd();
  978.     ProfileIntOut(g_szMovieX, lMovieOrgX);
  979.     ProfileIntOut(g_szMovieY, lMovieOrgY);
  980.  
  981.     SaveWindowPos(hwnd);
  982.     DestroyWindow(hwnd);
  983. }
  984.  
  985.  
  986. /*****************************Private*Routine******************************\
  987. * VideoCd_OnQueryEndSession
  988. *
  989. \**************************************************************************/
  990. BOOL
  991. VideoCd_OnQueryEndSession(
  992.     HWND hwnd
  993.     )
  994. {
  995.     SaveWindowPos(hwnd);
  996.     return TRUE;
  997. }
  998.  
  999.  
  1000. /******************************Public*Routine******************************\
  1001. * VideoCd_OnSize
  1002. *
  1003. \**************************************************************************/
  1004. void
  1005. VideoCd_OnSize(
  1006.     HWND hwnd,
  1007.     UINT state,
  1008.     int dx,
  1009.     int dy
  1010.     )
  1011. {
  1012.     if(IsWindow(g_hwndStatusbar))
  1013.     {
  1014.         int Pane[2] = {dx/2-8, -1};
  1015.  
  1016.         SendMessage(g_hwndStatusbar, WM_SIZE, 0, 0L);
  1017.         SendMessage(g_hwndStatusbar, SB_SETPARTS, 2, (LPARAM)Pane);
  1018.     }
  1019.  
  1020.     if(IsWindow(g_hwndTrackbar))
  1021.     {
  1022.         SetWindowPos(g_hwndTrackbar, HWND_TOP, LEFT_MARGIN, dyToolbar - 1,
  1023.             dx - (2 * LEFT_MARGIN), dyTrackbar, SWP_NOZORDER);
  1024.     }
  1025.  
  1026.     if(IsWindow(g_hwndToolbar))
  1027.     {
  1028.         SendMessage(g_hwndToolbar, WM_SIZE, 0, 0L);
  1029.     }
  1030.  
  1031.     RepositionMovie(hwnd);
  1032. }
  1033.  
  1034.  
  1035. /*****************************Private*Routine******************************\
  1036. * VideoCd_OnSysColorChange
  1037. *
  1038. \**************************************************************************/
  1039. void
  1040. VideoCd_OnSysColorChange(
  1041.     HWND hwnd
  1042.     )
  1043. {
  1044.     FORWARD_WM_SYSCOLORCHANGE(g_hwndToolbar, SendMessage);
  1045.     FORWARD_WM_SYSCOLORCHANGE(g_hwndStatusbar, SendMessage);
  1046. }
  1047.  
  1048.  
  1049. /*****************************Private*Routine******************************\
  1050. * VideoCd_OnInitMenuPopup
  1051. *
  1052. \**************************************************************************/
  1053. void
  1054. VideoCd_OnInitMenuPopup(
  1055.     HWND hwnd,
  1056.     HMENU hMenu,
  1057.     UINT item,
  1058.     BOOL fSystemMenu
  1059.     )
  1060. {
  1061.     UINT uFlags;
  1062.  
  1063.     switch(item)
  1064.     {
  1065.         case 0: // File menu
  1066.             if(g_State & (VCD_IN_USE | VCD_NO_CD | VCD_DATA_CD_LOADED))
  1067.                 uFlags = (MF_BYCOMMAND | MF_GRAYED);
  1068.             else
  1069.                 uFlags = (MF_BYCOMMAND | MF_ENABLED);
  1070.  
  1071.             EnableMenuItem(hMenu, IDM_FILE_CLOSE, uFlags);
  1072.  
  1073.             // Disable the "Open Second Stream" item if already opened
  1074.             if (g_bSecondFileLoaded)
  1075.                 EnableMenuItem(hMenu, IDM_FILE_OPEN2, MF_BYCOMMAND | MF_GRAYED);
  1076.             else
  1077.                 EnableMenuItem(hMenu, IDM_FILE_OPEN2, uFlags);
  1078.             break;
  1079.  
  1080.         case 1: // Properties menu
  1081.             if(g_State & (VCD_IN_USE | VCD_NO_CD | VCD_DATA_CD_LOADED))
  1082.                 uFlags = (MF_BYCOMMAND | MF_GRAYED);
  1083.             else
  1084.                 uFlags = (MF_BYCOMMAND | MF_ENABLED);
  1085.  
  1086.             EnableMenuItem(hMenu, IDM_APP_IMAGE, uFlags);
  1087.             EnableMenuItem(hMenu, IDM_STREAM_A, uFlags);
  1088.             EnableMenuItem(hMenu, IDM_CAPTURE_IMAGE, uFlags);
  1089.             EnableMenuItem(hMenu, IDM_DISPLAY_CAPTURED_IMAGE, uFlags);
  1090.  
  1091.             if (!g_bSecondFileLoaded)
  1092.                 uFlags = (MF_BYCOMMAND | MF_GRAYED);
  1093.             else
  1094.                 uFlags = (MF_BYCOMMAND | MF_ENABLED);
  1095.  
  1096.             EnableMenuItem(hMenu, IDM_STREAM_B, uFlags);
  1097.             break;
  1098.  
  1099.         case 2: // Help menu
  1100.             break;
  1101.     }
  1102. }
  1103.  
  1104.  
  1105. /*****************************Private*Routine******************************\
  1106. * VideoCd_OnGraphNotify
  1107. *
  1108. * This is where we get any notifications from the filter graph.
  1109. *
  1110. \**************************************************************************/
  1111. void
  1112. VideoCd_OnGraphNotify(
  1113.     void
  1114.     )
  1115. {
  1116.     long    lEventCode;
  1117.  
  1118.     lEventCode = pMpegMovie->GetMovieEventCode();
  1119.     switch(lEventCode)
  1120.     {
  1121.         case EC_STEP_COMPLETE:
  1122.             g_State &= ~VCD_STEPPING;
  1123.             SetPlayButtonsEnableState();
  1124.             break;
  1125.  
  1126.         case EC_COMPLETE:
  1127.         case EC_USERABORT:
  1128.         case EC_ERRORABORT:
  1129.             VcdPlayerStopCmd();
  1130.             SetPlayButtonsEnableState();
  1131.             break;
  1132.  
  1133.         default:
  1134.             break;
  1135.     }
  1136. }
  1137.  
  1138.  
  1139. /*****************************Private*Routine******************************\
  1140. * VideoCd_OnNotify
  1141. *
  1142. * This is where we get the text for the little tooltips
  1143. *
  1144. \**************************************************************************/
  1145. LRESULT
  1146. VideoCd_OnNotify(
  1147.     HWND hwnd,
  1148.     int idFrom,
  1149.     NMHDR FAR* pnmhdr
  1150.     )
  1151. {
  1152.     switch(pnmhdr->code)
  1153.     {
  1154.         case TTN_NEEDTEXT:
  1155.             {
  1156.                 LPTOOLTIPTEXT   lpTt;
  1157.  
  1158.                 lpTt = (LPTOOLTIPTEXT)pnmhdr;
  1159.                 LoadString(hInst, (UINT) lpTt->hdr.idFrom, lpTt->szText,
  1160.                     sizeof(lpTt->szText));
  1161.             }
  1162.             break;
  1163.     }
  1164.  
  1165.     return 0;
  1166. }
  1167.  
  1168.  
  1169. /*****************************Private*Routine******************************\
  1170. * VideoCd_OnMenuSelect
  1171. *
  1172. \**************************************************************************/
  1173. void
  1174. VideoCd_OnMenuSelect(
  1175.     HWND hwnd,
  1176.     HMENU hmenu,
  1177.     int item,
  1178.     HMENU hmenuPopup,
  1179.     UINT flags
  1180.     )
  1181. {
  1182.     TCHAR szString[STR_MAX_STRING_LEN + 1];
  1183.  
  1184.     /*
  1185.     ** Is it time to end the menu help ?
  1186.     */
  1187.     if((flags == 0xFFFFFFFF) && (hmenu == NULL))
  1188.     {
  1189.         SendMessage(g_hwndStatusbar, SB_SIMPLE, 0, 0L);
  1190.     }
  1191.  
  1192.     /*
  1193.     ** Do we have a separator, popup or the system menu ?
  1194.     */
  1195.     else if(flags & MF_POPUP)
  1196.     {
  1197.         SendMessage(g_hwndStatusbar, SB_SIMPLE, 0, 0L);
  1198.     }
  1199.     else if(flags & MF_SYSMENU)
  1200.     {
  1201.         switch(item)
  1202.         {
  1203.             case SC_RESTORE:
  1204.                 lstrcpy(szString, IdStr(STR_SYSMENU_RESTORE));
  1205.                 break;
  1206.  
  1207.             case SC_MOVE:
  1208.                 lstrcpy(szString, IdStr(STR_SYSMENU_MOVE));
  1209.                 break;
  1210.  
  1211.             case SC_MINIMIZE:
  1212.                 lstrcpy(szString, IdStr(STR_SYSMENU_MINIMIZE));
  1213.                 break;
  1214.  
  1215.             case SC_MAXIMIZE:
  1216.                 lstrcpy(szString, IdStr(STR_SYSMENU_MAXIMIZE));
  1217.                 break;
  1218.  
  1219.             case SC_TASKLIST:
  1220.                 lstrcpy(szString, IdStr(STR_SYSMENU_TASK_LIST));
  1221.                 break;
  1222.  
  1223.             case SC_CLOSE:
  1224.                 lstrcpy(szString, IdStr(STR_SYSMENU_CLOSE));
  1225.                 break;
  1226.         }
  1227.  
  1228.         SendMessage(g_hwndStatusbar, SB_SETTEXT, SBT_NOBORDERS|255,
  1229.             (LPARAM)(LPTSTR)szString);
  1230.         SendMessage(g_hwndStatusbar, SB_SIMPLE, 1, 0L);
  1231.         UpdateWindow(g_hwndStatusbar);
  1232.     }
  1233.  
  1234.     /*
  1235.     ** Hopefully it's one of ours
  1236.     */
  1237.     else
  1238.     {
  1239.         if((flags & MF_SEPARATOR))
  1240.         {
  1241.             szString[0] = g_chNULL;
  1242.         }
  1243.         else
  1244.         {
  1245.             lstrcpy(szString, IdStr(item + MENU_STRING_BASE));
  1246.         }
  1247.  
  1248.         SendMessage(g_hwndStatusbar, SB_SETTEXT, SBT_NOBORDERS|255,
  1249.             (LPARAM)(LPTSTR)szString);
  1250.         SendMessage(g_hwndStatusbar, SB_SIMPLE, 1, 0L);
  1251.         UpdateWindow(g_hwndStatusbar);
  1252.     }
  1253. }
  1254.  
  1255. /*****************************Private*Routine******************************\
  1256. * VideoCd_OnDropFiles
  1257. *
  1258. * -- handle a file-manager drop of a filename to indicate a movie we should
  1259. *    open.
  1260. *
  1261. \**************************************************************************/
  1262. void
  1263. VideoCd_OnDropFiles(
  1264.     HWND hwnd,
  1265.     HDROP hdrop)
  1266. {
  1267.     // if there is more than one file, simply open the first one
  1268.  
  1269.     // find the length of the path (plus the null
  1270.     int cch = DragQueryFile(hdrop, 0, NULL, 0) + 1;
  1271.     TCHAR * pName = new TCHAR[cch];
  1272.  
  1273.     DragQueryFile(hdrop, 0, pName, cch);
  1274.  
  1275.     // open the file
  1276.     ProcessOpen(pName);
  1277.  
  1278.     // update the toolbar state
  1279.     SetPlayButtonsEnableState();
  1280.  
  1281.     // free up used resources
  1282.     delete [] pName;
  1283.     DragFinish(hdrop);
  1284. }
  1285.  
  1286.  
  1287. /******************************Public*Routine******************************\
  1288. * SetPlayButtonsEnableState
  1289. *
  1290. * Sets the play buttons enable state to match the state of the current
  1291. * cdrom device.  See below...
  1292. *
  1293. *
  1294. *                 VCD Player buttons enable state table
  1295. * -------------------------------------------------------------------
  1296. * │E=Enabled D=Disabled      │ Play │ Pause │ Eject │ Stop  │ Other │
  1297. * -------------------------------------------------------------------
  1298. * │Disk in use               │  D   │  D    │  D    │   D   │   D   │
  1299. * -------------------------------------------------------------------
  1300. * │No video cd or data cdrom │  D   │  D    │  E    │   D   │   D   │
  1301. * -------------------------------------------------------------------
  1302. * │Video cd (playing)        │  D   │  E    │  E    │   E   │   E   │
  1303. * -------------------------------------------------------------------
  1304. * │Video cd (paused)         │  E   │  D    │  E    │   E   │   E   │
  1305. * -------------------------------------------------------------------
  1306. * │Video cd (stopped)        │  E   │  D    │  E    │   D   │   E   │
  1307. * -------------------------------------------------------------------
  1308. *
  1309. *
  1310. \**************************************************************************/
  1311. void
  1312. SetPlayButtonsEnableState(
  1313.     void
  1314.     )
  1315. {
  1316.     BOOL    fEnable;
  1317.     BOOL    fVideoLoaded;
  1318.  
  1319.     /*
  1320.     ** Do we have a video cd loaded.
  1321.     */
  1322.     if(g_State & (VCD_NO_CD | VCD_DATA_CD_LOADED | VCD_IN_USE))
  1323.     {
  1324.         fVideoLoaded = FALSE;
  1325.     }
  1326.     else
  1327.     {
  1328.         fVideoLoaded = TRUE;
  1329.     }
  1330.  
  1331.     /*
  1332.     ** Do the play button
  1333.     */
  1334.     if(fVideoLoaded
  1335.         && ((g_State & VCD_STOPPED) || (g_State & VCD_PAUSED)))
  1336.     {
  1337.         fEnable = TRUE;
  1338.     }
  1339.     else
  1340.     {
  1341.         fEnable = FALSE;
  1342.     }
  1343.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON, IDM_MOVIE_PLAY, fEnable);
  1344.  
  1345.     /*
  1346.     ** Do the stop button
  1347.     */
  1348.     if(fVideoLoaded
  1349.         && ((g_State & VCD_PLAYING) || (g_State & VCD_PAUSED)))
  1350.     {
  1351.         fEnable = TRUE;
  1352.     }
  1353.     else
  1354.     {
  1355.         fEnable = FALSE;
  1356.     }
  1357.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON, IDM_MOVIE_STOP, fEnable);
  1358.  
  1359.     /*
  1360.     ** Do the pause button
  1361.     */
  1362.     if(fVideoLoaded && (g_State & VCD_PLAYING))
  1363.     {
  1364.         fEnable = TRUE;
  1365.     }
  1366.     else
  1367.     {
  1368.         fEnable = FALSE;
  1369.     }
  1370.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON, IDM_MOVIE_PAUSE, fEnable);
  1371.  
  1372.  
  1373.     fEnable = FALSE;
  1374.     if(fVideoLoaded && pMpegMovie->CanMovieFrameStep())
  1375.     {
  1376.         if(!(g_State & VCD_STEPPING))
  1377.         {
  1378.             fEnable = TRUE;
  1379.         }
  1380.     }
  1381.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON, IDM_MOVIE_STEP, fEnable);
  1382.  
  1383.     /*
  1384.     ** Do the seeking buttons
  1385.     */
  1386.     if((g_State & VCD_PAUSED) || (!fVideoLoaded))
  1387.         fEnable = FALSE;
  1388.     else
  1389.         fEnable = TRUE;
  1390.  
  1391.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON,
  1392.         IDM_MOVIE_SKIP_FORE, fEnable);
  1393.  
  1394.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON,
  1395.         IDM_MOVIE_SKIP_BACK, fEnable);
  1396.  
  1397.     SendMessage(g_hwndToolbar, TB_ENABLEBUTTON,
  1398.         IDM_MOVIE_PREVTRACK, fEnable);
  1399. }
  1400.  
  1401.  
  1402. /*****************************Private*Routine******************************\
  1403. * GetAdjustedClientRect
  1404. *
  1405. * Calculate the size of the client rect and then adjusts it to take into
  1406. * account the space taken by the toolbar and status bar.
  1407. *
  1408. \**************************************************************************/
  1409. void
  1410. GetAdjustedClientRect(
  1411.     RECT *prc
  1412.     )
  1413. {
  1414.     RECT    rcTool;
  1415.  
  1416.     GetClientRect(hwndApp, prc);
  1417.  
  1418.     GetWindowRect(g_hwndToolbar, &rcTool);
  1419.     prc->top += (rcTool.bottom - rcTool.top);
  1420.  
  1421.     GetWindowRect(g_hwndTrackbar, &rcTool);
  1422.     prc->top += (rcTool.bottom - rcTool.top);
  1423.  
  1424.     GetWindowRect(g_hwndStatusbar, &rcTool);
  1425.     prc->bottom -= (rcTool.bottom - rcTool.top);
  1426. }
  1427.  
  1428.  
  1429. /******************************Public*Routine******************************\
  1430. * IdStr
  1431. *
  1432. * Loads the given string resource ID into the passed storage.
  1433. *
  1434. \**************************************************************************/
  1435. LPCTSTR
  1436. IdStr(
  1437.     int idResource
  1438.     )
  1439. {
  1440.     static TCHAR    chBuffer[ STR_MAX_STRING_LEN ];
  1441.  
  1442.     if(LoadString(hInst, idResource, chBuffer, STR_MAX_STRING_LEN) == 0)
  1443.     {
  1444.         return g_szEmpty;
  1445.     }
  1446.  
  1447.     return chBuffer;
  1448. }
  1449.  
  1450.  
  1451. /*****************************Private*Routine******************************\
  1452. * SetDurationLength
  1453. *
  1454. * Updates pane 0 on the status bar
  1455. *
  1456. \**************************************************************************/
  1457. void
  1458. SetDurationLength(
  1459.     REFTIME rt
  1460.     )
  1461. {
  1462.     TCHAR   szFmt[64];
  1463.     TCHAR   sz[64];
  1464.  
  1465.     g_TrackBarScale = 1.0;
  1466.     while(rt / g_TrackBarScale > 30000)
  1467.     {
  1468.         g_TrackBarScale *= 10;
  1469.     }
  1470.  
  1471.     SendMessage(g_hwndTrackbar, TBM_SETRANGE, TRUE,
  1472.         MAKELONG(0, (WORD)(rt / g_TrackBarScale)));
  1473.  
  1474.     SendMessage(g_hwndTrackbar, TBM_SETTICFREQ, (WPARAM)((int)(rt / g_TrackBarScale) / 9), 0);
  1475.     SendMessage(g_hwndTrackbar, TBM_SETPAGESIZE, 0, (LPARAM)((int)(rt / g_TrackBarScale) / 9));
  1476.  
  1477.     wsprintf(sz, TEXT("Length: %s"), FormatRefTime(szFmt, rt));
  1478.     SendMessage(g_hwndStatusbar, SB_SETTEXT, 0, (LPARAM)sz);
  1479. }
  1480.  
  1481.  
  1482. /*****************************Private*Routine******************************\
  1483. * SetCurrentPosition
  1484. *
  1485. * Updates pane 1 on the status bar
  1486. *
  1487. \**************************************************************************/
  1488. void
  1489. SetCurrentPosition(
  1490.     REFTIME rt
  1491.     )
  1492. {
  1493.     TCHAR   szFmt[64];
  1494.     TCHAR   sz[64];
  1495.  
  1496.     SendMessage(g_hwndTrackbar, TBM_SETPOS, TRUE, (LPARAM)(rt / g_TrackBarScale));
  1497.  
  1498.     wsprintf(sz, TEXT("Elapsed: %s"), FormatRefTime(szFmt, rt));
  1499.     SendMessage(g_hwndStatusbar, SB_SETTEXT, 1, (LPARAM)sz);
  1500. }
  1501.  
  1502.  
  1503. /*****************************Private*Routine******************************\
  1504. * FormatRefTime
  1505. *
  1506. * Formats the given RefTime into the passed in character buffer,
  1507. * returns a pointer to the character buffer.
  1508. *
  1509. \**************************************************************************/
  1510. TCHAR *
  1511. FormatRefTime(
  1512.     TCHAR *sz,
  1513.     REFTIME rt
  1514.     )
  1515. {
  1516.     // If we are not seeking in time then format differently
  1517.  
  1518.     if(pMpegMovie && pMpegMovie->GetTimeFormat() != TIME_FORMAT_MEDIA_TIME)
  1519.     {
  1520.         wsprintf(sz,TEXT("%s"),(LPCTSTR) CDisp((LONGLONG) rt,CDISP_DEC));
  1521.         return sz;
  1522.     }
  1523.  
  1524.     int hrs, mins, secs;
  1525.  
  1526.     rt += 0.49;
  1527.  
  1528.     hrs  =  (int)rt / 3600;
  1529.     mins = ((int)rt % 3600) / 60;
  1530.     secs = ((int)rt % 3600) % 60;
  1531.  
  1532.     wsprintf(sz, TEXT("%02d:%02d:%02d h:m:s"),hrs, mins, secs);
  1533.     return sz;
  1534. }
  1535.  
  1536. /*****************************Private*Routine******************************\
  1537. * InitStreamParams
  1538. *
  1539. \**************************************************************************/
  1540. void InitStreamParams(int i)
  1541. {
  1542.     CopyMemory(&strParam[i], strParamInit, sizeof(strParamInit));
  1543.  
  1544.     if(i == STRM_B)
  1545.     {
  1546.         strParam[STRM_B].Alpha = 0.5F;
  1547.     }
  1548. }
  1549.  
  1550.  
  1551. /*****************************Private*Routine******************************\
  1552. * UpdateAppImage
  1553. *
  1554. \**************************************************************************/
  1555. void
  1556. UpdateAppImage()
  1557. {
  1558.     VMRALPHABITMAP bmpInfo;
  1559.     ZeroMemory(&bmpInfo, sizeof(bmpInfo));
  1560.     bmpInfo.rDest.left = g_xPos;
  1561.     bmpInfo.rDest.top = g_yPos;
  1562.     bmpInfo.rDest.right = g_xPos + g_xSize;
  1563.     bmpInfo.rDest.bottom = g_yPos + g_ySize;
  1564.  
  1565.     bmpInfo.dwFlags = VMRBITMAP_SRCCOLORKEY;
  1566.     bmpInfo.clrSrcKey = 0;
  1567.  
  1568.     if(!g_fEnableAppImage)
  1569.     {
  1570.         bmpInfo.fAlpha = 0.0F;
  1571.     }
  1572.     else
  1573.     {
  1574.         bmpInfo.fAlpha = g_Alpha;
  1575.     }
  1576.  
  1577.     if (pMpegMovie)
  1578.         pMpegMovie->UpdateAppImage(&bmpInfo);
  1579. }
  1580.  
  1581.  
  1582. /*****************************Private*Routine******************************\
  1583. * AppImgDlgProc
  1584. *
  1585. \**************************************************************************/
  1586. BOOL CALLBACK
  1587. AppImgDlgProc(
  1588.     HWND hwnd,
  1589.     UINT uMsg,
  1590.     WPARAM wParam,
  1591.     LPARAM lParam
  1592.     )
  1593. {
  1594.     HWND hwndT;
  1595.     int pos;
  1596.     TCHAR sz[32];
  1597.  
  1598.     switch(uMsg)
  1599.     {
  1600.         case WM_INITDIALOG:
  1601.  
  1602.             hwndT = GetDlgItem(hwnd, IDC_XPOS_TRK);
  1603.             pos = int(1000 * g_xPos);
  1604.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(1000)));
  1605.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1606.             _stprintf(sz, TEXT("%.3f"), g_xPos);
  1607.             SetWindowText(hwndT, sz);
  1608.             SetDlgItemText(hwnd, IDC_XPOS, sz);
  1609.  
  1610.             pos = int(1000 * g_yPos);
  1611.             hwndT = GetDlgItem(hwnd, IDC_YPOS_TRK);
  1612.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(1000)));
  1613.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1614.             _stprintf(sz, TEXT("%.3f"), g_yPos);
  1615.             SetWindowText(hwndT, sz);
  1616.             SetDlgItemText(hwnd, IDC_YPOS, sz);
  1617.  
  1618.             pos = int(1000 * g_xSize);
  1619.             hwndT = GetDlgItem(hwnd, IDC_XSIZE_TRK);
  1620.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(1000)));
  1621.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1622.             _stprintf(sz, TEXT("%.3f"), g_xSize);
  1623.             SetWindowText(hwndT, sz);
  1624.             SetDlgItemText(hwnd, IDC_XSIZE, sz);
  1625.  
  1626.             pos = int(1000 * g_ySize);
  1627.             hwndT = GetDlgItem(hwnd, IDC_YSIZE_TRK);
  1628.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(1000)));
  1629.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1630.             _stprintf(sz, TEXT("%.3f"), g_ySize);
  1631.             SetDlgItemText(hwnd, IDC_YSIZE, sz);
  1632.  
  1633.             pos = int(1000 * g_Alpha);
  1634.             hwndT = GetDlgItem(hwnd, IDC_ALPHA_TRK2);
  1635.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(1000)));
  1636.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1637.             _stprintf(sz, TEXT("%.3f"), g_Alpha);
  1638.             SetDlgItemText(hwnd, IDC_ALPHA, sz);
  1639.  
  1640.             Button_SetCheck(GetDlgItem(hwnd, IDC_IMAGE_ENABLE), g_fEnableAppImage);
  1641.             return TRUE;
  1642.  
  1643.         case WM_COMMAND:
  1644.             switch(LOWORD(wParam))
  1645.             {
  1646.                 case IDOK:
  1647.                     EndDialog(hwnd, 1);
  1648.                     break;
  1649.  
  1650.                 case IDC_IMAGE_ENABLE:
  1651.                     g_fEnableAppImage =
  1652.                     Button_GetCheck(GetDlgItem(hwnd, IDC_IMAGE_ENABLE));
  1653.                     UpdateAppImage();
  1654.                     break;
  1655.             }
  1656.             return TRUE;
  1657.  
  1658.         case WM_HSCROLL:
  1659.             {
  1660.                 HWND hwndCtrl = (HWND)lParam;
  1661.  
  1662.                 if(GetDlgItem(hwnd, IDC_ALPHA_TRK2) == hwndCtrl)
  1663.                 {
  1664.                     pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1665.                     g_Alpha = (FLOAT)pos / 1000.0F;
  1666.                     UpdateAppImage();
  1667.                     _stprintf(sz, TEXT("%.3f"), g_Alpha);
  1668.                     SetDlgItemText(hwnd, IDC_ALPHA, sz);
  1669.                 }
  1670.                 else if(GetDlgItem(hwnd, IDC_XPOS_TRK) == hwndCtrl)
  1671.                 {
  1672.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1673.                         g_xPos = (FLOAT)pos / 1000.0F;
  1674.                         UpdateAppImage();
  1675.                         _stprintf(sz, TEXT("%.3f"), g_xPos);
  1676.                         SetDlgItemText(hwnd, IDC_XPOS, sz);
  1677.                 }
  1678.                 else if(GetDlgItem(hwnd, IDC_YPOS_TRK) == hwndCtrl)
  1679.                 {
  1680.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1681.                         g_yPos = (FLOAT)pos / 1000.0F;
  1682.                         UpdateAppImage();
  1683.                         _stprintf(sz, TEXT("%.3f"), g_yPos);
  1684.                         SetDlgItemText(hwnd, IDC_YPOS, sz);
  1685.                 }
  1686.                 else if(GetDlgItem(hwnd, IDC_XSIZE_TRK) == hwndCtrl)
  1687.                 {
  1688.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1689.                         g_xSize = (FLOAT)pos / 1000.0F;
  1690.                         UpdateAppImage();
  1691.                         _stprintf(sz, TEXT("%.3f"), g_xSize);
  1692.                         SetDlgItemText(hwnd, IDC_XSIZE, sz);
  1693.                 }
  1694.                 else if(GetDlgItem(hwnd, IDC_YSIZE_TRK) == hwndCtrl)
  1695.                 {
  1696.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1697.                         g_ySize = (FLOAT)pos / 1000.0F;
  1698.                         UpdateAppImage();
  1699.                         _stprintf(sz, TEXT("%.3f"), g_ySize);
  1700.                         SetDlgItemText(hwnd, IDC_YSIZE, sz);
  1701.                 }
  1702.             }
  1703.             return TRUE;
  1704.  
  1705.  
  1706.         default:
  1707.             return FALSE;
  1708.     }
  1709. }
  1710.  
  1711. /*****************************Private*Routine******************************\
  1712. * UpdatePinAlpha
  1713. *
  1714. \**************************************************************************/
  1715. void
  1716. UpdatePinAlpha(int strmID)
  1717. {
  1718.     STRM_PARAM* p = &strParam[strmID];
  1719.  
  1720.     if(pMpegMovie && pMpegMovie->m_pMixControl)
  1721.         pMpegMovie->m_pMixControl->SetAlpha(strmID, p->Alpha);
  1722. }
  1723.  
  1724. /*****************************Private*Routine******************************\
  1725. * UpdatePinPos
  1726. *
  1727. \**************************************************************************/
  1728. void
  1729. UpdatePinPos(int strmID)
  1730. {
  1731.     STRM_PARAM* p = &strParam[strmID];
  1732.     NORMALIZEDRECT r = {p->xPos, p->yPos, p->xPos + p->xSize, p->yPos + p->ySize};
  1733.  
  1734.     if(pMpegMovie && pMpegMovie->m_pMixControl)
  1735.         pMpegMovie->m_pMixControl->SetOutputRect(strmID, &r);
  1736. }
  1737.  
  1738.  
  1739. /*****************************Private*Routine******************************\
  1740. * TransDlgProc
  1741. *
  1742. \**************************************************************************/
  1743. BOOL CALLBACK
  1744. TransDlgProc(
  1745.     HWND hwnd,
  1746.     UINT uMsg,
  1747.     WPARAM wParam,
  1748.     LPARAM lParam
  1749.     )
  1750. {
  1751.     TCHAR sz[32];
  1752.     HWND hwndT;
  1753.     int pos;
  1754.  
  1755.     static int strmID;
  1756.     STRM_PARAM* p = &strParam[strmID];
  1757.  
  1758.     switch(uMsg)
  1759.     {
  1760.         case WM_INITDIALOG:
  1761.  
  1762.             strmID = (int)lParam;
  1763.             p = &strParam[strmID];
  1764.  
  1765.             SetWindowText(hwnd, TEXT("Video Transition Properties"));
  1766.             ShowWindow(GetDlgItem(hwnd, IDC_IMAGE_ENABLE), SW_HIDE);
  1767.  
  1768.             hwndT = GetDlgItem(hwnd, IDC_XPOS_TRK);
  1769.             pos = int(10000 * p->xPos) + 10000;
  1770.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(20000)));
  1771.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1772.             _stprintf(sz, TEXT("%.3f"), p->xPos);
  1773.             SetWindowText(hwndT, sz);
  1774.             SetDlgItemText(hwnd, IDC_XPOS, sz);
  1775.  
  1776.             pos = int(10000 * p->yPos) + 10000;
  1777.             hwndT = GetDlgItem(hwnd, IDC_YPOS_TRK);
  1778.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(20000)));
  1779.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1780.             _stprintf(sz, TEXT("%.3f"), p->yPos);
  1781.             SetWindowText(hwndT, sz);
  1782.             SetDlgItemText(hwnd, IDC_YPOS, sz);
  1783.  
  1784.             pos = int(10000 * p->xSize) + 10000;
  1785.             hwndT = GetDlgItem(hwnd, IDC_XSIZE_TRK);
  1786.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(20000)));
  1787.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1788.             _stprintf(sz, TEXT("%.3f"), p->xSize);
  1789.             SetWindowText(hwndT, sz);
  1790.             SetDlgItemText(hwnd, IDC_XSIZE, sz);
  1791.  
  1792.             pos = int(10000 * p->ySize) + 10000;
  1793.             hwndT = GetDlgItem(hwnd, IDC_YSIZE_TRK);
  1794.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(20000)));
  1795.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1796.             _stprintf(sz, TEXT("%.3f"), p->ySize);
  1797.             SetWindowText(hwndT, sz);
  1798.             SetDlgItemText(hwnd, IDC_YSIZE, sz);
  1799.  
  1800.             pos = int(10000 * p->Alpha);
  1801.             hwndT = GetDlgItem(hwnd, IDC_ALPHA_TRK2);
  1802.             SendMessage(hwndT, TBM_SETRANGE, TRUE, MAKELONG(0, (WORD)(10000)));
  1803.             SendMessage(hwndT, TBM_SETPOS, TRUE, (LPARAM)(pos));
  1804.             _stprintf(sz, TEXT("%.3f"), p->Alpha);
  1805.             SetWindowText(hwndT, sz);
  1806.             SetDlgItemText(hwnd, IDC_ALPHA, sz);
  1807.             return TRUE;
  1808.  
  1809.         case WM_COMMAND:
  1810.             switch(LOWORD(wParam))
  1811.             {
  1812.                 case IDOK:
  1813.                     EndDialog(hwnd, 1);
  1814.                     break;
  1815.             }
  1816.             return TRUE;
  1817.  
  1818.         case WM_HSCROLL:
  1819.             {
  1820.                 HWND hwndCtrl = (HWND)lParam;
  1821.  
  1822.                 if(GetDlgItem(hwnd, IDC_ALPHA_TRK2) == hwndCtrl)
  1823.                 {
  1824.                     pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1825.                     p->Alpha = (FLOAT)pos / 10000.0F;
  1826.                     UpdatePinAlpha(strmID);
  1827.                     _stprintf(sz, TEXT("%.3f"), p->Alpha);
  1828.                     SetDlgItemText(hwnd, IDC_ALPHA, sz);
  1829.                 }
  1830.                 else if(GetDlgItem(hwnd, IDC_XPOS_TRK) == hwndCtrl)
  1831.                 {
  1832.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1833.                         p->xPos = ((FLOAT)pos - 10000.F) / 10000.0F;
  1834.                         UpdatePinPos(strmID);
  1835.                         _stprintf(sz, TEXT("%.3f"), p->xPos);
  1836.                         SetDlgItemText(hwnd, IDC_XPOS, sz);
  1837.                 }
  1838.                 else if(GetDlgItem(hwnd, IDC_YPOS_TRK) == hwndCtrl)
  1839.                 {
  1840.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1841.                         p->yPos = ((FLOAT)pos - 10000.F) / 10000.0F;
  1842.                         UpdatePinPos(strmID);
  1843.                         _stprintf(sz, TEXT("%.3f"), p->yPos);
  1844.                         SetDlgItemText(hwnd, IDC_YPOS, sz);
  1845.                 }
  1846.                 else if(GetDlgItem(hwnd, IDC_XSIZE_TRK) == hwndCtrl)
  1847.                 {
  1848.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1849.                         p->xSize = ((FLOAT)pos - 10000.F) / 10000.0F;
  1850.                         UpdatePinPos(strmID);
  1851.                         _stprintf(sz, TEXT("%.3f"), p->xSize);
  1852.                         SetDlgItemText(hwnd, IDC_XSIZE, sz);
  1853.                 }
  1854.                 else if(GetDlgItem(hwnd, IDC_YSIZE_TRK) == hwndCtrl)
  1855.                 {
  1856.                         pos = (int)SendMessage(hwndCtrl, TBM_GETPOS, 0, 0);
  1857.                         p->ySize = ((FLOAT)pos - 10000.F) / 10000.0F;
  1858.                         UpdatePinPos(strmID);
  1859.                         _stprintf(sz, TEXT("%.3f"), p->ySize);
  1860.                         SetDlgItemText(hwnd, IDC_YSIZE, sz);
  1861.                 }
  1862.             }
  1863.             return TRUE;
  1864.  
  1865.         default:
  1866.             return FALSE;
  1867.     }
  1868. }
  1869.  
  1870.  
  1871.  
  1872. LRESULT CALLBACK AboutDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1873. {
  1874.     switch(message)
  1875.     {
  1876.         case WM_INITDIALOG:
  1877.             return TRUE;
  1878.  
  1879.         case WM_COMMAND:
  1880.             if(wParam == IDOK)
  1881.             {
  1882.                 EndDialog(hWnd, TRUE);
  1883.                 return TRUE;
  1884.             }
  1885.             break;
  1886.     }
  1887.     return FALSE;
  1888. }
  1889.  
  1890.  
  1891.  
  1892.